// JavaScript Document

function slider_ds() {
	//
	this.slider_ct = null;
	this.slider_c = 0;
	this.slider = null;
	this.slider_status = 0;
	//
	this.image_select = function(eid){
		if( this.slider_status == 0 ) return;
		document.location.hash = eid;
		this.slider.click(eid);
		if( this.slider_c > 0 && this.slider_ct ){
			dremoveClass(this.slider_ct, "item-current");
		}
		this.slider_c = eid;
		this.slider_ct = $E("gitem_"+eid);
		daddClass(this.slider_ct, "item-current");
		return false;
	};
	this.image_over = function(obj){
		daddClass(obj, "item-over");
	};
	this.image_out = function(obj){
		dremoveClass(obj, "item-over");
	};
	this.image_current = function(){
		var eid = parseInt(document.location.hash.substring(1));
		if( eid > 0 ){
			this.image_select(eid);
		} else {
			this.slider.start();
		}
	};
	this.image_previous = function(){
		if( this.slider_status == 0 ) return;
		if( this.slider_c > 0 ){
			var eid = this.slider._psprevious(this.slider_c);
			this.image_select(eid);
		}
	};
	this.image_next = function(){
		if( this.slider_status == 0 ) return;
		if( this.slider_c > 0 ){
			var eid = this.slider._psnext(this.slider_c);
			this.image_select(eid);
		}
	};
	this.img_previous = function(){
		if( this.slider_status == 0 ) return;
		if( this.slider_c > 0 ){
			var eid = this.slider._psprevious(this.slider_c,4);
			this.image_select(eid);
		}
	};
	this.img_next = function(){
		if( this.slider_status == 0 ) return;
		if( this.slider_c > 0 ){
			var eid = this.slider._psnext(this.slider_c,4);
			this.image_select(eid);
		}
	};
	this.img_ds = function(){
		window.setInterval(function(){
				if($E("gimg_auto").value == 1){
					this.image_next();
				}
				}, 3000);
	};
	//
	this.start = function(){
		var _obj = this;
		//
		addEvent($E("gimagep"),"click",function(){_obj.image_previous();});
		addEvent($E("gimaged"),"click",function(){_obj.image_next();});
		addEvent($E("gimagen"),"click",function(){_obj.image_next();});
		addEvent($E("gimgp"),"click",function(){_obj.img_previous();});
		addEvent($E("gimgn"),"click",function(){_obj.img_next();});
		//
		var i = 0;
		var a = $E("glist").getElementsByTagName("DIV");
		for(i=0; i<a.length; i++){
			if(a[i].id.indexOf("gitem_")>-1){
				addEvent(a[i],"mouseover",function(){_obj.image_over(this);});
				addEvent(a[i],"mouseout",function(){_obj.image_out(this);});
				addEvent(a[i],"click",function(){_obj.image_select(this.id.replace("gitem_",""));});
			}
		}
		//
		this.slider = new slider_image("glist", "gimage");
		this.slider.init();
		//
		this.slider_status = 1;
		//
		this.image_current();
		//this.img_ds();
	};
}